﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SeaBattle.Domain.Abstract.Services;
using SeaBattle.Domain.Entities;

namespace SeaBattle.Domain.Concrete.Services
{
    public class FakeAccountService: IAccountService
    {
        private static int defaultBalance = 1000;

        private static Dictionary<string, int> accountRests = 
            new Dictionary<string, int>{
            {"vasya",10000},
            {"alex",500},
            {"andrew",300}
        };
        /// <summary>
        /// Gets the player balance.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public int GetPlayerBalance(Player player)
        {
            if(accountRests.ContainsKey(player.Login))
            {
                return accountRests[player.Login];
            }
            throw new Exception("Player with name "+player.Name+" hasnt any balance");
        }


        public void SetPlayerBalance(Player player, int balance)
        {
            if (!accountRests.Keys.Contains(player.Login))
                accountRests.Add(player.Login, balance);
            else
                accountRests[player.Login] = balance;
        }


        public int DefaultBalance
        {
            get { return defaultBalance; }
        }
    }
}
